package com.pr.makfilm.user.pages.room.create.design;

import com.pr.makfilm.domain.Room;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Pawel
 * Date: 07.10.13
 * Time: 14:42
 * To change this template use File | Settings | File Templates.
 */
public class DesignCellRepeater extends RepeatingView
{
   private List<DesignCell> cells = new ArrayList<DesignCell>();

   private int rowId;

   public DesignCellRepeater(String id, IModel<?> model, int rowId)
   {
      super(id, model);
      this.rowId = rowId;
   }

   @Override
   protected void onPopulate()
   {
      removeAll();
      Room room = (Room) getDefaultModelObject();
      for (int i = 0; i < room.getColumnCount(); i++)
      {
         DesignCell cell = new DesignCell(newChildId(), rowId, i);
         cells.add(cell);
         add(cell);
      }
   }

   public List<DesignCell> getCells()
   {
      return cells;
   }
}
